package itu.dk.bosk.ex4;

public class SimpleTracing {
    public static void main(String[] args) {
        String message = null;
        printInUpperCase(message);
    }

    public static void printInUpperCase(String stringToPrint) {
        String stringInUpperCase = convertToUpperCase(stringToPrint);
        System.out.println(stringInUpperCase);
    }

    public static String convertToUpperCase(String stringIn) {
        String stringOut = stringIn.toUpperCase(); 
        return stringOut;
    }
}

/*
 * Reply to excersise 4-3
 *
 * a) A java.lang.NullPointerException was thrown..
 *
 * b)
 * public class NullPointerException extends RuntimeException
 * Thrown when an application attempts to use null in a case where an object is required. These include:
 *
 * Calling the instance method of a null object. Accessing or modifying the field of a null object.
 * Taking the length of null as if it were an array. Accessing or modifying the slots of null as if it were an array.
 * Throwing null as if it were a Throwable value. Applications should throw instances of this class to indicate other illegal uses of the null object.
 *
 * c)
 * The exception is thrown at lin 15, and bubles through line 10 to line 6 in the main
 * method, where it's outputted, as it is not handled in any way.
 *
 * d)
 * 6: This is the line that gives the exception.. The exception is show because it can't be
 * "bubble" any higher.
 *
 * 10: This line also recieves an exception, but it will pass it on to the code at
 * line 6, where it might be handled.
 *
 * 15: This line throws the exception, because of the attempt to assign null to a string.
 * The exception is passed on to line 10, where it might be handled.
 */
